// Copyright 2006 Mloofle Inc. All Rights Reserved.
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Creates an input stream based on the specified file name.
 */
public class FileStreamCreator {

  /**
   * Create an input stream based on the specified file name.
   * 
   * @param fileName the file to open
   * @return an input stream to the file
   * @throws FileNotFoundException if the file does not exist
   * @throws IOException if the file cannot be read from
   */
  public static InputStream createInputStream(String fileName)
      throws FileNotFoundException, IOException {
    File file = new File(fileName);
    if (!file.exists()) {
      throw new FileNotFoundException(fileName);
    }
    try {
      FileInputStream fileInputStream = new FileInputStream(file);
      return fileInputStream;
    } catch (Throwable e) {
      throw (IOException) new IOException().initCause(e);
    }
  }

  /**
   * Not instantiable.
   */
  private FileStreamCreator() {
  }

}
